<HTML>
<HEAD>
<LINK REL="stylesheet" TYPE="text/css" HREF="this.css">
</HEAD>
<BODY>
    <H1>Reliable Software Mandatory project: TS14</H1>
      <P>
	TS14 is a simple working hours classifcation and reporting
	system (TimeSag). It is based upon entering data into a simple
	text file using a simple format which is then processed using
	the TS14 application that can output various statistics
	regarding surplus work, amount of time worked on categories,
	etc.
      </P>
      <P>
	The TS14 architecture is a traditional (old-school :)
	<EM>parse, build, output</EM> architecture. Each line is read,
	parsed, and its contents processed. Finally a report is
	output.
      </P>

      <H2>Input format specification</H2>

      <P>
	The format is line-oriented and consists of a set of valid line
	types. Each line is defined by a number of <EM>tokens</EM>. (A
	token is a string delimited by whitespace: spaces or tabulator).
      </P>
      <P>
	An example of an input file is given below:
      </P>
<PRE>
# Timesag system for NN 2013
	
# ===================================== Karakteristika for &aring;r
HoursOvertime = 502.2
Year = 2013

# ============================================================

Week 1 :	3	:	0

Wed    		Ca				8.00
	adm		-		1
	sa		exam		3	forb question

	sa		exam		1

	sa		exam		2
Thu		No		
	syg		-		4.5
	sa		exam		3
Fri		Ho				8-
	sa		exam		1
	n4c		-		1
	itevmd		-		1
	mtt		-		1

	mtt		plan		2
	saip		plan		1.5


Week 2 :	5	:	0

Mon		Ca				8.00-
	sa		exam		4
	
	sa		exam		2

	adm		-		1
Tue		Ca				8.30
	sa		exam		3.5
	
	sa		exam		2.5
	adm		-		0.5
	itevmd		-		0.5

Wed		Ca				8.00
	adm		-		0.5
	sa		exam		3.5

	sa		exam		3
	itevmd		-		0.5
	
Thu		Ca				8.00
	adm		-		0.5
	sa		exam		3.5

	sa		exam		4
	
Fri		Ca				8.00-16.30
	adm		-		0.5
	censor		-		0.5
	n4c		e2e		3

	sa		protokol	2
	saip		-		0.5
	itevmd		-		0.5
	sa		social		1.5

Sat		No
	sa		hotciv		1	rette hotciv kode til

	es		litt		1.5

Week 3 :	5	:	0

Mon		Ca				8.30-15.30
	adm		-		0.5
	es		-		0.5
	sa		-		1
	adm		-		1.5

	book2		errata		1
	es		-		2.5


	terna		course		1.5
</PRE>

      <P>
	The input file format has six different types of lines:
      </P>
      <UL>
	<LI> Assignment line
	  <PRE>
HoursOvertime = 502.2
	  </PRE>
	  A three token line. First token is alphabetic, next is "=",
	    and third is integer.  Assign a value to an internal
	    variable in the script.
	</LI>
	<LI> Week specification line
	  <PRE>
Week 1 :	3	:	0
	  </PRE>
	  A 6 token line, that marks the beginning of a new week. The
	  format must be strictly obeyed and provides information
	  about the week number, the number of actual working days in
	  the week, and finally the number of days the must be counted
	  as part of the person's own holidays. Thus in the example
	  above, week 1 had 3 working days and the person did not take
	  any vacation that week. Only valid week numbers are allowed,
	  and only the interval 0..5 is valid for the other two integers.
	</LI>
	<LI> Weekday specification line
	  <PRE>
Fri		Ca				8.00-16.30
	  </PRE>
	  A two token line, that marks the beginning of a weekday. The
	  first token identifies the weekday, only the seven three
	  letter weekday strings are accepted (Mon, Tue, Wed, Thu,
	  Fri, Sat, Sun), all other make the script flag an error. The
	  second token is the transportation mode used that day and
	  only the following set of strings are accepted (Bi, Ca, Pu,
	  Tr, No, Ho). The rest of the line is considered a comment
	  and may be anything.

	  <BR>
	  The meaning of the transportation mode string is <CODE>
	  Bi = Bicycle, Ca = Car, Pu = Public Transport (bus), Tr =
	  Travel (airplane, train), No = Not applicable (weekend
	  work), Ho = Home (work from home).</CODE>
	</LI>
	<LI> Work specification line
	  <PRE>
	censor	-		7.5
	  </PRE>
	  A three token line classifying amount of hours worked on a
	  category and subcategory. The line must contain whitespace
	  before the first token. The first token is any string
	  starting with a letter. The second token is any string
	  starting with a letter OR just the single character "-". The
	  third token is a hour value, restricted to half hours. Thus
	  "3" and "3.5" are value but not "3.3" as it is not a half
	  hour value.
	</LI>
	<LI>
	  Empty lines or lines beginning with a '#' (comment lines)
	  are ignored.
	</LI>
      </UL>

      <H3>Sequence constraints</H3>

      <P>
	The lines in the input cannot be arbitrarily sequenced. The
	following rules must be obeyed:
      </P>

      <UL>
	<LI>
	  All assignment lines shall be BEFORE any other type lines.
	</LI>
	<LI>
	  Any weekday specification line shall be AFTER a week
	  specification line.
	</LI>
	<LI>
	  Any work specification line shall be AFTER a weekday
	  specification line.
	</LI>
	<LI>
	  Empty lines and comment lines can appear in any place.
	</LI>
	<LI>
	  There can be at most two consecutive empty lines. Three or
	  more empty lines in sequence is illegal.
	</LI>
      </UL>

      
      
      <H2>Ouput specification</H2>

      <P>
	Three types of reports has to be generated from the TS14: 
	weekly overview, category overview, and transport mode
	overview.
      </P>

      
      <H3>Weekly overview</H3>

      <P>The purpose of this report is to describe how much is worked
      each week, and keep a running total of surplus work compared to
      a normal working week (here fixed to 37 hours/5 working
      days). The report contains a single line pr week, exemplified by
      the following format
      <PRE>
=== Week Overview ===
Week   1 :   22.0 hours   (  3 Wdays of   7.3  d=502.0)
Week   2 :   40.5 hours   (  5 Wdays of   8.1  d=505.5)
Week   3 :    7.0 hours   (  5 Wdays of   1.4  d=475.5)
...
      </PRE>
      That is, one line per week showing the
      <OL>
	<LI>Week number</LI>
	<LI> Accumulated number of hours worked that week (*)</LI>
	<LI> Number of working days that week (Wdays)</LI>
	<LI> Average number of hours worked per working day, rounded
	to one decimal.
	</LI>
	<LI>
	  Accumulated surplus hours (delta) over the whole year,
	  assuming a 37 hours working week. For the first week, the
	  value of the "HoursOvertime" variable is added (surplus
	  hours from the year before is maintained.)
	</LI>
      </OL>
      </P>

      <P>
	(*) The accumulation specifically avoids counting hours worked
	on any category that is classified as "consulting" (see below)
	which is the case for the "terna" task on Monday in Week 3.
      </P>
      
      
      <H3>Category overview</H3>


      <P>The purpose of this report is to accumulate hours work on
      specific categories and classify these into five main classes
      (teaching, research, adm, misc, or consulent). The report
      contains a single line for each category, showing the number
      of hours work on it. Each category is listed in its relevant
      class.

      </P>


<PRE>
-- Time spent on classes and categories --
teaching                  47.0 ( 68%)
    saip     :     2.0
    censor   :     0.5
    sa       :    41.5
    mtt      :     3.0
research                   9.5 ( 14%)
    es       :     4.5
    book2    :     1.0
    n4c      :     4.0
misc                       4.5 (  6%)
    syg      :     4.5
consulent                  1.5 (  2%)
    terna    :     1.5
adm                        8.5 ( 12%)
    itevmd   :     2.5
    adm      :     6.0
Total:                    69.5 (71)
                          ===============
</PRE>

    <P>
      Three types of lines are output:
    </P>
    <P>
<PRE>
teaching                  47.0 ( 68%)
</PRE>
     The category name is output, followed by accumulated hours in
     this category, followed by the total percentage of hours worked
     in this category. The percentage is of the total amount of hours
     EXCLUDING hours classified as consulting. (Thus the sum may
     exceed 100%, as is the case above!).
    </P>

    <P>
<PRE>
    sa       :    41.5
</PRE>
    Number of hours worked on this category.
    </P>

    <P>
<PRE>
Total:                    69.5 (71)
</PRE>
    Total number of hours worked, excluding and including hours worked
    on class "consulting". 
    </P>

    <P>
      The set of classes and the mapping from category to class is
      ideally configurable, but in this exercise given by the example
      output above.
    </P>


    

    <H3>Transport mode overview</H3>

    <P>
      The purpose of this report is to classify and count the number
      of days using a specific means of transportation to work.
    </P>

<PRE>
-------------------------------------------------------------------------
| Car:     7     Bicycle:    0     Public:     0    Traveling:    0     |
| Home:    1    NonWDays:    2     Unknown:    0                        |
-------------------------------------------------------------------------
</PRE>
  <P> The individual entries in the report match one-to-one with the
  transportation mode categories described in the input format
  section.
</P>
   

    </BODY>
</HTML>
